﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using QL_LichCT.Entities;



namespace QL_LichCT.DataLayer
{
    class GIANGVIENDAL
    {
        //Xac dinh quyen cua mot tai khoan
        public static object GetQuyen(string column, string id, string pass)
        {
            DataAccessHelper db = new DataAccessHelper();

            string select = String.Format("select {2} from GIANGVIEN a join CHUCVU b on a.macv = b.macv where macb = '{0}' and password = '{1}'", id, pass, column);
            object quyen = db.GetVaule(select);
            return quyen;
        }

        public static List<GIANGVIEN> GetListByTC(string column, object value)
        {
            DataAccessHelper db = new DataAccessHelper();

            string sql = string.Format("select * from GIANGVIEN where {0} = {1}", column, value);
            DataTable dt = db.GetDataTable(sql);

            List<GIANGVIEN> list = new List<GIANGVIEN>();

            foreach (DataRow row in dt.Rows)
                list.Add(new GIANGVIEN(row));
            return list;
        }


        public static object GetColumnByTC(string column, string tc, object value)
        {
            DataAccessHelper db = new DataAccessHelper();

            string sql = string.Format("select {0} from GIANGVIEN where {1} = {2}", column, tc, value);
            object kq = db.GetVaule(sql);
            return kq;
        }
    }
}
